from rename_menu import rename_menu

class mediator_fake :
    def __init__ ( self ) :
        self . _hide_browser = False
        self . _rename_menu_title = None
        self . _rename_menu_rename = None
        self . _rename_menu_new_name = None
        self . _rename_menu_already_exists = None
        self . _rename_menu_no_entries = None
        self . _on_rename_menu_return = False
        self . _rename_base_in_browser = False
        self . _configured_title_text = None
        self . _configured_title_text_before_show_browser = None
        self . _configured_action_text = None
        self . _configured_action_text_before_show_browser = None
        self . _configured_action_title_name_text = None
        self . _configured_action_title_name_text_before_show_browser = None
        self . _configured_only_unique_names_mode = None
        self . _configured_only_unique_names_mode_before_show_browser = None
        self . _configured_title_text_when_no_entries = None
        self . _configured_title_text_when_no_entries_before_show_browser = None
        self . _configured_remove_action_part_when_no_entries = None
        self . _configured_remove_action_part_when_no_entries_before_show_browser = None
    def show_browser ( self ) :
        self . _configured_title_text_before_show_browser = self . _configured_title_text
        self . _configured_action_text_before_show_browser = self . _configured_action_text
        self . _configured_action_title_name_text_before_show_browser = self . _configured_action_title_name_text
        self . _configured_only_unique_names_mode_before_show_browser = self . _configured_only_unique_names_mode
        self . _configured_title_text_when_no_entries_before_show_browser = self . _configured_title_text_when_no_entries
        self . _configured_remove_action_part_when_no_entries_before_show_browser = self . _configured_remove_action_part_when_no_entries
    def hide_browser ( self ) :
        self . _hide_browser = True
    def configure_title_text_for_browser ( self , title_text ) :
        self . _configured_title_text = title_text
    def configure_action_text_for_browser ( self , action_text ) :
        self . _configured_action_text = action_text
    def configure_action_title_name_text_for_browser ( self , action_title_name_text ) :
        self . _configured_action_title_name_text = action_title_name_text
    def configure_only_unique_names_mode_for_browser ( self , already_exists_text ) :
        self . _configured_only_unique_names_mode = already_exists_text
    def configure_title_text_when_no_entries_for_browser ( self , title_text ) :
        self . _configured_title_text_when_no_entries = title_text
    def configure_remove_action_part_when_no_entries_for_browser ( self ) :
        self . _configured_remove_action_part_when_no_entries = True
    def localization_rename_menu_title ( self ) :
        return self . _rename_menu_title
    def localization_rename_menu_rename ( self ) :
        return self . _rename_menu_rename
    def localization_rename_menu_new_name ( self ) :
        return self . _rename_menu_new_name
    def localization_rename_menu_already_exists ( self ) :
        return self . _rename_menu_already_exists
    def localization_rename_menu_no_entries ( self ) :
        return self . _rename_menu_no_entries
    def on_rename_menu_return ( self ) :
        self . _on_rename_menu_return = True
    def rename_base_in_browser ( self ) :
        self . _rename_base_in_browser = True

class rename_menu_tests :
    'rename_menu'
    def __init__ ( self , test ) :
        self . _test = test
        self . _mediator = mediator_fake ( )
        self . _rename_menu = rename_menu ( self . _mediator )
        
    #
    # show_rename_menu
    #
        
    def test_show_rename_menu_configure_title_text_for_browser ( self ) :
        self . _mediator . _rename_menu_title = 'my title'
        self . _rename_menu . show_rename_menu ( )
        self . _test . assume_equal ( self . _mediator . _configured_title_text_before_show_browser , 'my title' )
    def test_show_rename_menu_configure_action_text_for_browser ( self ) :
        self . _mediator . _rename_menu_rename = 'my rename'
        self . _rename_menu . show_rename_menu ( )
        self . _test . assume_equal ( self . _mediator . _configured_action_text_before_show_browser , 'my rename' )
    def test_show_rename_menu_configure_action_title_name_text_for_browser ( self ) :
        self . _mediator . _rename_menu_new_name = 'my new name'
        self . _rename_menu . show_rename_menu ( )
        self . _test . assume_equal ( self . _mediator . _configured_action_title_name_text_before_show_browser , 'my new name' )
    def test_show_rename_menu_configure_only_unique_names_mode_for_browser ( self ) :
        self . _mediator . _rename_menu_already_exists = 'my already exists'
        self . _rename_menu . show_rename_menu ( )
        self . _test . assume_equal ( self . _mediator . _configured_only_unique_names_mode_before_show_browser , 'my already exists' )
    def test_show_rename_menu_configure_title_text_when_no_entries_for_browser ( self ) :
        self . _mediator . _rename_menu_no_entries = 'my no entries'
        self . _rename_menu . show_rename_menu ( )
        self . _test . assume_equal ( self . _mediator . _configured_title_text_when_no_entries_before_show_browser , 'my no entries' )
    def test_show_rename_menu_configure_remove_action_part_when_no_entries_for_browser ( self ) :
        self . _rename_menu . show_rename_menu ( )
        self . _test . assume_true ( self . _mediator . _configured_remove_action_part_when_no_entries_before_show_browser )

    #
    # hide_rename_menu
    #
            
    def test_hide_rename_menu_hide_browser ( self ) :
        self . _rename_menu . hide_rename_menu ( )
        self . _test . assume_true ( self . _mediator . _hide_browser )

    #
    # on_browser_return
    #
        
    def test_on_browser_return_on_rename_menu_return ( self ) :
        self . _rename_menu . show_rename_menu ( )
        self . _rename_menu . on_browser_return ( )
        self . _test . assume_true ( self . _mediator . _on_rename_menu_return )
    def test_on_browser_return_do_nothing_before_show ( self ) :
        self . _rename_menu . on_browser_return ( )
        self . _test . assume_false ( self . _mediator . _on_rename_menu_return )
    def test_on_browser_return_do_nothing_after_hide ( self ) :
        self . _rename_menu . show_rename_menu ( )
        self . _rename_menu . hide_rename_menu ( )
        self . _rename_menu . on_browser_return ( )
        self . _test . assume_false ( self . _mediator . _on_rename_menu_return )
        
    #
    # on_browser_action
    #

    def test_on_browser_action_rename_base_in_browser ( self ) :
        self . _rename_menu . show_rename_menu ( )
        self . _rename_menu . on_browser_action ( )
        self . _test . assume_true ( self . _mediator . _rename_base_in_browser )
    def test_on_browser_action_do_nothing_before_show ( self ) :
        self . _rename_menu . on_browser_action ( )
        self . _test . assume_false ( self . _mediator . _rename_base_in_browser )
    def test_on_browser_action_do_nothing_after_hide ( self ) :
        self . _rename_menu . show_rename_menu ( )
        self . _rename_menu . hide_rename_menu ( )
        self . _rename_menu . on_browser_action ( )
        self . _test . assume_false ( self . _mediator . _rename_base_in_browser )
